#ifndef LAURIN_DISCOVER_DEVICES_H_
#define LAURIN_DISCOVER_DEVICES_H_

#include "laurin-module.h"
#include "laurin-monitor-device.h"
#include "laurin-80211-frame.h"
#include "laurin-network.h"
#include <glibmm/ustring.h>
#include <pcap.h>


void processFrameExtForDevices(u_char* arg, const struct pcap_pkthdr *header,const u_char *data);


class LaurinDiscoverDevicesModule : public LaurinModule
{
	friend void processFrameExtForDevices(u_char* arg, const struct pcap_pkthdr *header,const u_char *data);

	public:

		LaurinDiscoverDevicesModule(const Glib::ustring& ifaceName, const Glib::ustring& masterIfaceName);
		virtual ~LaurinDiscoverDevicesModule();

		bool isInitialized();
		void setMaxNumberOfFrame(int max);
		int getMaxNumberOfFrame() const;

		void elaborateFrames();

		LaurinNetworkSet* getNetworkSet();

		void setLocationEnable(bool enable);
		bool isLocationEnabled() const;

	protected:

		virtual void run();
		virtual void innerStop();

	private:

		std::list<u_int8_t*> _ap;							// list of ap
		std::list<Laurin80211Frame> _frames;				// the received frames
		LaurinNetworkSet* _networks;
		LaurinMonitorDevice* _device;
		int _max;
		bool _location;

		void processFrame(const struct pcap_pkthdr *header,const u_char *data);
		void clearResources();

};

#endif
